﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Ledict.ConditionExtract.BLL
{
    public class ParagraphToSentence
    {

        public void GetSentenceByOnePara(string Paragraph, string RegText, int ParagraphTypeId, ref   List<string>  returnDic)
        {
           
            if (RegText != "")
            {
                MatchCollection matchs = System.Text.RegularExpressions.Regex.Matches(Paragraph, RegText);

                foreach (Match str in matchs)//分段
                {
                    MatchCollection matchschild = System.Text.RegularExpressions.Regex.Matches(str.ToString(), @"(?<=^|。|\r|\n|；)[^。|；]*?(?:).*?(?:。|；)");
                    foreach (Match strchild in matchschild)//分句
                    {
                        if (strchild.ToString() != "")
                        {
                            returnDic.Add(strchild.ToString());
                        }
                    }
                }
            }
           

        }

        public List<string>  GetSentence(string Paragraph, int ParagraphTypeId)
        {
            List<string> returnDic = new List<string>();
         
            switch (ParagraphTypeId)
            {
                case 140:
                   
                    GetSentenceByOnePara(Paragraph, @"经(本院)?审理查明.+", 140, ref returnDic);//查明部分

                    break;
                case 150:
                    GetSentenceByOnePara(Paragraph, @".+(?=(判决|裁定)?如下(协议)?[：:])", 150, ref returnDic );//裁判理由

                    break;
               
            }
            return returnDic;
        }
    }
}
